import Mock from 'mockjs'; // 引入mockjs
import Qs from 'qs';
const Random = Mock.Random;  // Mock.Random 是一个工具类，用于生成各种随机数据
const VITE_API_URL = import.meta.env.VITE_APP_BASE_API;


//  登录接口/mall4cloud_auth/user_addr/list
Mock.mock(
  new RegExp(VITE_API_URL + '/mall4cloud_auth/user_addr/list' + '.*'),
  'get',
  (options?: object): any => {
    let tempObj = Mock.mock({
      "lists|1-10": [
        {
          "province|+1": [
            Random.province(),
            Random.province(),
            Random.province()
          ],
          'city|+1':[
            Random.city(),
            Random.city(),
            Random.city()
          ],
          'area|+1':[
            Random.county(),
            Random.county(),
            Random.county()
          ],
          'isDefault':Random.integer(0,1)
        }
      ]
    })
    let result = [  ...tempObj.lists ]
    
    console.log(result,'/mall4cloud_auth/user_addr/list')
    return result
  }
)

//  接口/mall4cloud_product/a/shop_cart/info
Mock.mock(
  new RegExp(VITE_API_URL + '/mall4cloud_product/a/shop_cart/info' + '.*'),
  'get',
  (options?: object): any => {
    let tempObj = Mock.mock({
      'shopCarts|1-10': [
        {
          
          'shopCartItem|1-10':[
            {
              'cartItemId|+1':[Random.guid(),Random.guid(),Random.guid()],
              'imgUrl|+1': [
                Random.image('200x100', '#FF6600'),
                Random.image('200x100', '#FF6600'),
                Random.image('200x100', '#FF6600')
              ],
              'checked':Random.integer(0,1),
              'spuId':Random.guid(),
              'skuName':Random.ctitle(2,4),
              'priceFee':Random.integer(30000,90000),
              'count':Random.integer(10,50)
            }
          ]
        }
      ],
      'totalMoney':Random.integer(50000,100000)
    })
    let result = tempObj
    
    console.log(result,'/mall4cloud_product/a/shop_cart/info')
    return result
  }
)

// 接口/mall4cloud_product/a/shop_cart/check_items
Mock.mock(
  new RegExp(VITE_API_URL + '/mall4cloud_product/a/shop_cart/check_items' + '.*'),
  'get',
  (options?: object): any => {
    let tempObj = Mock.mock({
      'shopCarts|1-10': [
        {
          'shopCartItem|1-10':[
            {
              'cartItemId|+1':[Random.guid(),Random.guid(),Random.guid()],
              'imgUrl|+1': [
                Random.image('200x100', '#FF6600'),
                Random.image('200x100', '#FF6600'),
                Random.image('200x100', '#FF6600')
              ],
              'checked':Random.integer(0,1),
              'spuId':Random.guid(),
              'skuName':Random.ctitle(2,4),
              'priceFee':Random.integer(30000,90000),
              'count':Random.integer(10,50)
            }
          ]
        }
      ],
      'totalMoney':Random.integer(50000,100000)
    })
    let result = tempObj
    
    console.log(result,'/mall4cloud_product/a/shop_cart/check_items')
    return result
  }
)